const { getArticleList, getArticleDetails } = require('@/service/article')

class ArticleController {
  async articleList (ctx, next) {
    const res = await getArticleList()
    try {
      ctx.body = {
        message: '获取列表成功',
        data: res
      }
      return ctx
    } catch(err) {
      console.error('获取列表失败', err)
    }
  }
  async articleDetails(ctx, next) {
    const article_id = ctx.request.query
    const res = await getArticleDetails({article_id})
    try {
      ctx.body = {
        message: '获取详情成功',
        data: res
      }
      return ctx
    } catch(err){
      console.error('获取详情失败', err)
    }
  }
}

module.exports = new ArticleController()